package com.example.shoppingmall.community.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.shoppingmall.R;

import com.example.shoppingmall.community.bean.HotPostBean;
import com.example.shoppingmall.home.adapter.HotGridViewAdapter;

import java.util.List;

public class HotPostListViewAdapter extends BaseAdapter {
    private final List<HotPostBean.ResultDTO> result;
    private Context mContext;

    public HotPostListViewAdapter(Context mContext, List<HotPostBean.ResultDTO> ressult){
        this.mContext = mContext;
        this.result = ressult;
    }
    @Override
    public int getCount() {
        return result.size();
    }

    @Override
    public Object getItem(int i) {
        return result.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if(view ==null){
            view = View.inflate(mContext, R.layout.item_hotpost_listview,null);
            holder = new ViewHolder();
            holder.tv_hot_username = (TextView) view.findViewById(R.id.tv_hot_username);
            holder.tv_hot_addtime = (TextView) view.findViewById(R.id.tv_hot_addtime);
            holder.tv_hot_saying = (TextView) view.findViewById(R.id.tv_hot_saying);
            holder.tv_hot_likes = (TextView) view.findViewById(R.id.tv_hot_likes);
            holder.tv_hot_comments = (TextView) view.findViewById(R.id.tv_hot_comments);
            holder.iv_hot_figure = (ImageView) view.findViewById(R.id.iv_hot_figure);
            holder.ll_hot_post = (LinearLayout) view.findViewById(R.id.ll_hot_post);
            holder.ib_new_post_avatar = (ImageButton) view.findViewById(R.id.ib_new_post_avatar);
            view.setTag(holder);
        }else{
            holder = (ViewHolder) view.getTag();
        }

        return view;
    }
    static class ViewHolder{
        TextView tv_hot_username;
        TextView tv_hot_addtime;
        ImageView iv_hot_figure;
        LinearLayout ll_hot_post;
        TextView tv_hot_saying;
        TextView tv_hot_likes;
        TextView tv_hot_comments;
        ImageButton ib_new_post_avatar;


    }
}
